Skip to content

feat(cmp-firebase): commonMain-first Firebase (Analytics + Crashlytics, 15 targets) + crash→GA4 delivery audit fixes - #158

Merged
mobilebytesenseicommunity merged 6 commits into
MobileByteLabs:devfrom
therajanmaurya:session-kmp-toolkit-20260821162600499
Aug 25, 2026
Merged

feat(cmp-firebase): commonMain-first Firebase (Analytics + Crashlytics, 15 targets) + crash→GA4 delivery audit fixes#158
mobilebytesenseicommunity merged 6 commits into
MobileByteLabs:devfrom
therajanmaurya:session-kmp-toolkit-20260821162600499

Conversation

@therajanmaurya

@therajanmaurya therajanmaurya commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator

Summary

Delivers cmp-firebase as a commonMain-first Firebase library (unified Analytics + Crashlytics, one in-library setup surface across all 15 KMP targets) and then hardens the crash→GA4 delivery path via a full audit. The headline is a single, all-platform GA4 crash view: native Crashlytics on the 6 GitLive targets, and a Measurement-Protocol / app_crash bridge everywhere else — so every platform lands in one GA4/BigQuery table segmentable by kmp_platform. Companion cmp-firebase-compose stays a thin commonMain analytics layer.

Changes

commonMain-first Firebase surface

  • FirebaseKit.initialize() / initialize(config) — one idempotent setup call; FirebaseConfig/FirebaseOptions builder; Android auto-init via FirebaseInitProvider; FirebaseRuntime config holder.
  • Analytics: AnalyticsHelper + GitLive FirebaseAnalyticsHelper (firebaseMain tier) and a free Measurement-Protocol helper (nonFirebaseMain tier), kmp_platform auto-tagging, DI factory, NoOp/Stub/Test variants.
  • Crashlytics: CrashReporter + FirebaseCrashReporter (native) / LoggingCrashReporter (fallback), CrashAnalyticsBridgeapp_crash GA4 mirror.
  • expect/actual across jvm · android · ios ×3 · macos ×2 · tvos ×3 · linux ×2 · mingw · js · wasmJs (15 targets), via firebaseMain/nonFirebaseMain + crashlyticsFirebaseMain/crashlyticsFallbackMain flavor source sets.

Audit fixes (crash→GA4 delivery)

  • MP snake_case (critical): MpRequest now emits client_id/user_id/user_properties via @SerialName — camelCase caused GA4 to 2xx-and-silently-drop every MP event (defeated the whole fallback + free-crash path). Locked by MpSerializationTest.
  • Shared analytics singleton: provideAnalyticsHelper() memoizes one process-wide instance (reset on initialize(config)) so the app's DI and the crash bridge share consent + MP client_id (was a consent leak). Locked by a singleton test.
  • Opt-in uncaught capture: FirebaseKit.installUncaughtHandler() — real on JVM/Android (chains existing handler → recordException(fatal=true)), safe no-op on native/js/wasm.
  • Fatal not lost to debounce: app_crash MP events flush immediately instead of on the 5s debounce.
  • fatal flag reachable: asCoroutineExceptionHandler(fatal) + recording(fatal) overloads (the GA4 fatal dimension was always false).
  • DEBUG bridge wired: CrashReporterModule.Mode.Logging now passes an analytics sink.
  • Docs/scaffold truth: corrected JVM→nonFirebase tier tables; removed phantom watchOS (orphan Platform.watchos.kt + overstated 20/21→15 target counts — a dep, cmp-network-monitor, has no watchOS targets).

API compatibility

BCV re-dumped as additive-only — the fatal variants and the LoggingCrashReporter analytics sink are added as overloads / a secondary constructor, preserving every original signature (no binary-breaking removals). apiCheck green.

Notable files

  • src/commonMain/.../FirebaseKit.kt, FirebaseConfig.kt, analytics/mp/MeasurementProtocolAnalyticsHelper.kt, crashlytics/CrashAnalyticsBridge.kt, crashlytics/LoggingCrashReporter.kt
  • src/commonMain/.../UncaughtHandler.kt (+ jvm/android real, native/js/wasmJs no-op actuals)
  • Tests: MpSerializationTest, AnalyticsTierRoutingTest, CrashAnalyticsBridgeTest, PlatformInjectionTest, FirebaseConfigTest

Verified inline: jvm/js/wasmJs/macosArm64/android/linuxX64/metadata compile, jvmTest green, apiCheck green.

Documentation & secrets mapping

  • README.md / DEVELOPMENT.md refreshed for the cleaner API: FirebaseKit.initialize(config) builder, installUncaughtHandler(), provideAnalyticsHelper() singleton, fatal-aware capture, crash→GA4 single view. Corrected all target counts to the real 15 (10 GitLive analytics + 5 MP fallback; 6 GitLive crash + 9 logging) and removed every phantom watchOS claim (cmp-network-monitor dep ships no watchOS artifact) — including residual library-source KDocs.
  • docs/firebase/SETUP.md + CLAUDE_AI_SETUP.md: keys & secrets made org-global-explicit. Analytics is a single GA4 property; org-level secrets = mbs-firebase-sa + mbs-ga4-property-id; project-level per app = google-services.json / plist / app-ids / ga4-measurement-id / mp-api-secret. Added an org-vs-project → vault-alias mapping table + the automatic secrets-resolve-path.sh --emit tier resolution rule. Fixed a property-id-vs-measurement-id conflation.
  • cmp-firebase (the library) needs ONLY project-level secrets; the only genuinely-sensitive one is <proj>-mp-api-secret. The org SA + property id are read-side (growth dashboard), never consumed by the library.

@coderabbitai

coderabbitai Bot commented Aug 21, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: a9382ef0-d04f-4160-a290-0b310139f2c6


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

…e.kts cmp-firebase/src/androidMain/kotlin/io/github/mobilebytelabs/kmptoolkit/firebase/FirebaseInitProvider.kt
@therajanmaurya therajanmaurya changed the title cmp-firebase commonMain feat(cmp-firebase): fully-commonMain programmatic Firebase init via one FirebaseConfig Aug 21, 2026
@therajanmaurya therajanmaurya changed the title feat(cmp-firebase): fully-commonMain programmatic Firebase init via one FirebaseConfig feat(cmp-firebase): programmatic commonMain Firebase init via FirebaseKit.initialize(config) Aug 23, 2026
…ase/build.gradle.kts cmp-firebase/src/commonMain/kotlin/io/github/mobilebytelabs/kmptoolkit/firebase/FirebaseKit.kt
@therajanmaurya therajanmaurya changed the title feat(cmp-firebase): programmatic commonMain Firebase init via FirebaseKit.initialize(config) feat(cmp-firebase): commonMain-first Firebase (Analytics + Crashlytics, 15 targets) + crash→GA4 delivery audit fixes Aug 25, 2026
….md cmp-firebase/src/commonMain/kotlin/io/github/mobilebytelabs/kmptoolkit/firebase/FirebaseConfig.kt
…bilebytelabs/kmptoolkit/firebase/analytics/InMemorySettings.kt cmp-firebase/src/commonMain/kotlin/io/github/mobilebytelabs/kmptoolkit/firebase/crashlytics/CrashReporterExtensions.kt cmp-firebase/src/commonMain/kotlin/io/github/mobilebytelabs/kmptoolkit/firebase/crashlytics/di/CrashReporterModule.kt
@mobilebytesenseicommunity
mobilebytesenseicommunity marked this pull request as ready for review August 25, 2026 19:06
@mobilebytesenseicommunity
mobilebytesenseicommunity merged commit dda2380 into MobileByteLabs:dev Aug 25, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants